package com.cndw.kungfu.event;

import com.cndw.kungfu.config.ConstantsConfig;
import com.cndw.kungfu.config.ConstantsSystem;
import com.cndw.kungfu.ext.LogUtil;
import com.cndw.kungfu.model.Context;

/**
 * 服务器关服通知
 * 
 * @author fantadust [9677889@qq.com]
 * @date 2011-12-29 下午1:17:03
 */
public class GamePowerHandler extends BaseHandler implements Runnable {

	private boolean open;
	
	public GamePowerHandler(boolean open){
		this.open = open;
	}
	
	@Override
	public void run() {
		
		if (open) {
			commOpen();
		}else {
			commShutDown();
		}	

	}
	
	public static void commOpen(){
		LogUtil.getMain().info("power open start...");
		ConstantsConfig.setSysClosed(false);
		ConstantsSystem.setPowerOpenTime(0);
	}

	public static void commShutDown() {
		LogUtil.getMain().info("power shutdown start...");
		Context.getBusinessServer().updateConfig("sysClosed", "1");
		GameShutdownHandler shutdown = new GameShutdownHandler();
		ConstantsSystem.setCloseState(1);
		shutdown.start();
	}

}
